package com.wang.spring.lifecycle.b_jsr250;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class Pen2 {

    private Integer inks;

    public Pen2() {
        System.out.println("pen2 初始化，构造方法");
    }


    public void open() {
        System.out.println("init-method 打开钢笔");
    }

    public void close() {
        System.out.println("destroy-method 合上钢笔");
    }


    @PostConstruct
    public void addInks() {
        this.inks = 10;
        System.out.println("@PostConstruct  开始执行 加墨水");
    }


    @PreDestroy
    public void outInks() {
        this.inks = 0;
        System.out.println("@PreDestroy  销毁 导出墨水");
    }

    @Override
    public String toString() {
        return "Pen{" +
                "inks=" + inks +
                '}';
    }


    public Integer getInks() {
        return inks;
    }

    public void setInks(Integer inks) {
        System.out.println("pen2 setInks 方法调用 ");
        this.inks = inks;
    }
}
